﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using MFTool;

namespace AutoUI.Areas.ConfigUI.EasyUICtrl
{
    public class TextBox : CtrlBase
    {
        public TextBox(string id, EasyUICtrlPrepareData pData)
            : base(id, pData)
        {
            if (_dataOption.Count == 0)
            {
                _dataOption = DefaultValue.TextBoxJson().JsonToDictionary();
            }
        }
        public override void Prepare()
        {
            DomStr = "input";
            _class.Add("easyui-textbox");

            //删除引号
            if (!string.IsNullOrEmpty(_dataOption.GetValue("onChange")))
            {
                _dataOption.SetValue("onChange", "!-" + _dataOption.GetValue("onChange") + "-!");
            }
            else
            {
                _dataOption.Remove("onChange");
            }
        }

        public override void PrepareSearchCtrl()
        {
            Prepare();
            _dataOption.Clear();
            _style.SetValue("width", "100%");
        }
        
        public override string GetScript()
        {
            return "";
        }

        protected override void AfterDataOptionToJson(ref string dataOption)
        {
            dataOption = dataOption.Replace("\"!-", "").Replace("-!\"", "");
        }
    }
}